package com.easyedu.student.dao;

import com.easyedu.core.entity.po.StudentSelect;
import com.easyedu.student.entity.DO.StudentGrade;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author lmr
 **/
@Mapper
public interface StudentSelectDao {

    /**
     * 功能描述: 获取学生已选课程</br>
     * 数据表: student_select 学生选课表, open_course 学年开课表
     *
     * @param instituteId   1 开课学院id
     * @param departmentId  2 开课专业id
     * @param openYear      3 开放年份
     * @param schoolYear    4 开放学年
     * @param semester      5 开放学期
     * @param studentNumber 6 学生序号
     * @return : java.util.List<com.easyedu.api.entity.DO.StudentSelect>
     **/
    @Select("select * from student_select where student_number = #{studentNumber} AND open_courses_id in (select open_courses_id " +
            "from open_course where open_year = #{openYear} AND school_year = #{schoolYear} AND semester = #{semester}" +
            "AND open_institute_id = #{instituteId} AND open_department_id = #{departmentId})")
    List<StudentSelect> getHasSelectCourse(Long instituteId, Long departmentId, Integer openYear, String schoolYear, String semester, Long studentNumber);

    /**
     * 功能描述: 查询学生已选课程成绩</br>
     * 数据表: open_course 学年开课表, student_select 学生选课表
     *
     * @param studentNumber 1 学生序号
     * @return : java.util.List<com.easyedu.api.entity.DO.OpenCourse>
     **/
    @Select("select open_year,school_year,semester,student_select.course_code,student_select.course_name,usual_score," +
            "student_select.usual_score_ratio,experiment_score,student_select.experiment_score_ratio,exam_score," +
            "student_select.exam_score_ratio,total_score from open_course,student_select where student_select" +
            ".student_number = #{studentNumber} AND student_select.is_effective = 2 AND student_select" +
            ".open_courses_id = open_course.open_courses_id")
    List<StudentGrade> getStudentGrade(Long studentNumber);
}
